import 'package:lcapp/data/message_data_entity.dart';

messageDataEntityFromJson(MessageDataEntity data, Map<String, dynamic> json) {
	if (json['sysMsg'] != null) {
		data.sysMsg = MessageItem().fromJson(json['sysMsg']);
	}
	if (json['hdMsg'] != null) {
		data.hdMsg = MessageItem().fromJson(json['hdMsg']);
	}
	if (json['friendMsg'] != null) {
		data.friendMsg = MessageItem().fromJson(json['friendMsg']);
	}
	if (json['sysUnReadCount'] != null) {
		data.sysUnReadCount = json['sysUnReadCount'] is String
				? int.tryParse(json['sysUnReadCount'])
				: json['sysUnReadCount'].toInt();
	}
	if (json['hdUnReadCount'] != null) {
		data.hdUnReadCount = json['hdUnReadCount'] is String
				? int.tryParse(json['hdUnReadCount'])
				: json['hdUnReadCount'].toInt();
	}
	if (json['friendUnReadCount'] != null) {
		data.friendUnReadCount = json['friendUnReadCount'] is String
				? int.tryParse(json['friendUnReadCount'])
				: json['friendUnReadCount'].toInt();
	}
	return data;
}

Map<String, dynamic> messageDataEntityToJson(MessageDataEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['sysMsg'] = entity.sysMsg?.toJson();
	data['hdMsg'] = entity.hdMsg?.toJson();
	data['friendMsg'] = entity.friendMsg?.toJson();
	data['sysUnReadCount'] = entity.sysUnReadCount;
	data['hdUnReadCount'] = entity.hdUnReadCount;
	data['friendUnReadCount'] = entity.friendUnReadCount;
	return data;
}

messageItemFromJson(MessageItem data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['targetUserId'] != null) {
		data.targetUserId = json['targetUserId'] is String
				? int.tryParse(json['targetUserId'])
				: json['targetUserId'].toInt();
	}
	if (json['fromUserId'] != null) {
		data.fromUserId = json['fromUserId'] is String
				? int.tryParse(json['fromUserId'])
				: json['fromUserId'].toInt();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['content'] != null) {
		data.content = json['content'].toString();
	}
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['entryId'] != null) {
		data.entryId = json['entryId'] is String
				? int.tryParse(json['entryId'])
				: json['entryId'].toInt();
	}
	if (json['readState'] != null) {
		data.readState = json['readState'] is String
				? int.tryParse(json['readState'])
				: json['readState'].toInt();
	}
	if (json['session'] != null) {
		data.session = json['session'] is String
				? int.tryParse(json['session'])
				: json['session'].toInt();
	}
	if (json['entryType'] != null) {
		data.entryType = json['entryType'] is String
				? int.tryParse(json['entryType'])
				: json['entryType'].toInt();
	}
	if (json['exta'] != null) {
		data.exta = json['exta'].toString();
	}
	return data;
}

Map<String, dynamic> messageItemToJson(MessageItem entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['targetUserId'] = entity.targetUserId;
	data['fromUserId'] = entity.fromUserId;
	data['title'] = entity.title;
	data['content'] = entity.content;
	data['createTime'] = entity.createTime;
	data['entryId'] = entity.entryId;
	data['readState'] = entity.readState;
	data['session'] = entity.session;
	data['entryType'] = entity.entryType;
	data['exta'] = entity.exta;
	return data;
}